package algotradingfx.strategies.trees;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import algotradingfx.utils.Constants;
import algotradingfx.utils.FXAsset;
import atp.client.trading.strategies.StrategyPush;
import atp.commons.util.StrategyInfo;
import atp.commons.util.Tick;

public class TreeStrategy extends StrategyPush {
	/**
	 * 
	 */
	private static final long serialVersionUID = 5093946158086796917L;

	private static final String STRATEGY_NAME = "TreeStrategy";
	private static final String DATA_SET_FILE_NAME = "TreeStrategyDataSet";
	// private TickDataSet trainingSet;

	public TreeStrategy(String ssID, String password) {
		super(new StrategyInfo(STRATEGY_NAME), ssID, password);
	}

	/**
	 * 
	 * @return the probability of the tick in which it will go up and down
	 */
	private double trainAndPredict(String period) {
		double probability = 0.0;
		// run rdt against the input set
		String[] cmdarrays = { "rdt", "-f", DATA_SET_FILE_NAME + period, "-u",
				"-t", "100", "-i", "3456" };

		try {
			Process rdt = Runtime.getRuntime().exec(cmdarrays);
			BufferedReader reader = new BufferedReader(new InputStreamReader(
					rdt.getInputStream()));
			// probability = 0.0;
			try {

			} finally {
				reader.close();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return probability;
	}

	private void buildDataSet(){
		
	}
	
	@Override
	public void initialise() {
		declare(FXAsset.EURUSD.toString(), Constants.MOCK_BROKER);
	}
	
	@Override
	public boolean run(Object o) {
		buildDataSet();
		double probability1Tick = trainAndPredict("3M");
		double probability1Min = trainAndPredict("1M");
		//...
		// try to draw probabilility that will go up and down
		// if it is greater or less than a threshold, action, otherwise, do
		// nothing
		return false;
	}
}
